<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>openGauss Blog  | benchmark使用</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    
    <link rel="shortcut icon" href="https://xzx666.gitee.io/lookeng/img/favicon.ico" type="image/x-icon" />
    <link rel="apple-touch-icon" href="https://xzx666.gitee.io/lookeng/img/apple-touch-icon.png" />

    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/commen.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/blog.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/mobile.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/pagination.css?t=1607593672000">
    
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?34e9f585f29581007941aa1698181871";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
</head>
<body>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>






<div class="container">
    <div class="columns blog-detail">
        <div class="post_detail">
            <div class="is-child box">
                <div class="breadCrumb"><a href="\zh\">博客/</a></div>
                <div class="blog-detail-header">
                    <h1>benchmark使用</h1>
                    <div class="blog-detail-prop">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-date.png">
                        <span class="article_right_date">2020-07-25</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-author.png">
                        <span class="article_right_author">zhijing</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-view.png">
                        <span id="/zh/post/optimize/opengauss-tpcc/" class="leancloud_visitors" data-flag-title="benchmark使用">
                            <i class="leancloud-visitors-count"></i>                     
                        </span>
                    </div>
                    <div class="blog-detail-tags">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-tag.png">
                        
                        <a href="https://xzx666.gitee.io/lookeng/zh/tags/benchmark%E4%BD%BF%E7%94%A8">benchmark使用</a>
                        
                    </div>
                </div>
                <div class="content blog-content">
                    

<h3 id="概述">概述</h3>

<p>TPC-C是一种衡量联机事务处理OLTP能力的测试标准，模拟了在线订单处理系统应用环境，可以通过benchmark工具，来测试数据库的性能指标。<br />
TPC-C测试指标为tpmC，每分钟处理订单交易的数量。值越大表示数据库性能越优。<br />
本文介绍使用benchmark来跑opengauss数据库步骤，以及<code>htop iostat</code>两个服务器性能监控工具。</p>

<h3 id="java安装配置">java安装配置</h3>

<p>下载jdk到服务器并解压(例如解压到目录/usr/share/java/jdk1.8.0_232)；<br />
<code>vim /etc/profile</code> 增加环境变量：</p>

<pre><code class="language-shell">
export JAVA_HOME=/usr/share/java/jdk1.8.0_232
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/jre
export PATH=${PATH}:${JAVA_HOME}/bin
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

</code></pre>

<p>导入环境变量 <code>source /etc/profile</code>
输入 <code>java -version</code> 查看是否配置成功</p>

<h3 id="ant安装配置">ant安装配置</h3>

<p>下载ant并解压（解压路径例如 /usr/share/ant/apache-ant-1.10.8），
<code>vim /etc/profile</code> 增加环境变量：</p>

<pre><code class="language-shell">
export ANT_HOME=/usr/share/ant/apache-ant-1.10.8
export PATH=${PATH}:${ANT_HOME}/bin

</code></pre>

<p>导入环境变量 <code>source /etc/profile</code>
输入 <code>ant -version</code> 查看是否配置成功</p>

<h3 id="benchmark安装使用">benchmark安装使用</h3>

<p>下载benchmark</p>

<p>点击 <a href="../images/benchmarksql-5.0.zip">benchmark下载</a>或者到（<a href="https://sourceforge.net/projects/benchmarksql/）下载benchmark，在linux服务器上解压。">https://sourceforge.net/projects/benchmarksql/）下载benchmark，在linux服务器上解压。</a></p>

<p><strong>1. 替换jdbc驱动jar包</strong></p>

<p>进入到解压后的目录<code>benchmarksql-5.0/lib/postgres</code>下，从官网下载对应的jdbc驱动解压出来后放到该目录下：</p>

<p><img src="../images/tpcc1.png" alt="" /></p>

<p><strong>2. 使用ant编译benchmark</strong></p>

<p>进入到benchmark安装的根目录下，输入ant，进行编译：</p>

<pre><code class="language-shell">
cd /opt/benchmark/benchmarksql-5.0/
ant

</code></pre>

<p><img src="../images/tpcc2.png" alt="" /></p>

<p><strong>3. 创建tpcc数据库以及数据库用户</strong></p>

<p>登录到目标数据库里面：</p>

<pre><code class="language-sql">
create database tpccdb;
create user tpcc with password '&lt;password&gt;';
grant all privilege to tpcc;

</code></pre>

<p><strong>4. 配置benchmark的props.pg</strong></p>

<p>进入到<code>benchmarksql-5.0/run</code>目录下，修改props.pg文件数据库配置内容：</p>

<pre><code>db=tpccdb
driver=org.postgresql.Driver
conn=jdbc:postgresql://&lt;hostip&gt;:&lt;dbport&gt;/tpccdb
user=tpcc
password=&lt;password&gt;
</code></pre>

<p><strong>5. 运行benchmark</strong></p>

<pre><code class="language-shell">
sh runDatabaseBuild.sh props.pg  ## 生成测试数据
sh runBenchmark.sh props.pg      ## TPCC测试

</code></pre>

<h3 id="htop工具">htop工具</h3>

<p>htop是linux上面一个监控工具,可以认为是加强版的top，tpcc运行过程中，推荐使用htop进行监控资源状态</p>

<p>htop安装，使用yum源一键安装</p>

<pre><code class="language-shell">
yum install htop

</code></pre>

<p>使用的时候，输入 <code>htop</code> 就可以进入到htop监控窗口</p>

<p><img src="../images/htop.png" alt="" /></p>

<h3 id="iostat工具">iostat工具</h3>

<p>iostat工具对系统磁盘进行监控，分析磁盘的读写状态<br />
安装：</p>

<pre><code class="language-shell">
yum install sysstat

</code></pre>

<p>使用时候，输入 <code>iostat</code> 就可以查看磁盘读写状态</p>

                </div>
            </div>
            <div class="box" style="margin-top:15px;">
                <div style="font-size:14px;color:gray"><strong>【免责声明】</strong>本文仅代表作者本人观点，与本网站无关。本网站对文中陈述、观点判断保持中立，不对所包含内容的准确性、可靠性或完整性提供任何明示或暗示的保证。本文仅供读者参考，由此产生的所有法律责任均由读者本人承担。</div>
            </div>
            <div class="post-comment">
                
                  
  <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/custom.css" />
  <div id="vcomments" lang="zh-cn" mess="说点什么吧..."></div>

  <script type="text/javascript">
    const placeholder = document.getElementById("vcomments").getAttribute("mess"),
          lang = document.getElementById("vcomments").getAttribute("lang");
    const  langs = lang == "zh-cn" ? "zh-cn" : "en";
    new Valine({
        el: '#vcomments' ,
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm', 
        placeholder: placeholder,
        visitor: true,
		    meta: ['nick','mail','link'],
        lang: langs
    });
  </script>
            </div>
        </div>
    </div>
</div>
<script>
    $(function (){
        var query = new AV.Query('Counter');
        query.equalTo('url', decodeURIComponent('\/zh\/post\/optimize\/opengauss-tpcc\/'));
        query.find().then(function (data) {
            if(data.length && (data[0].attributes.author === 'openGauss')){
                var counter = AV.Object.createWithoutData('Counter', data[0].id);
                counter.set('author', 'zhijing');
                counter.save();
            }
        })
    })
</script>







<input id="iframeUrl" type="text" style="display: none;" value=https://xzx666.gitee.io/>




<script defer src="https://xzx666.gitee.io/lookengjs/all.js"></script>
<script src="https://xzx666.gitee.io/lookengjs/flexible.js"></script>
<script>
  const hash = window.location.search,
        pageurl = window.location.href;
  var langss = document.querySelector("html").lang === "zh-cn" ? "zh" : "en";
  console.log("hash:",hash,"pageurl:",pageurl,"ttr",pageurl.split(langss + "/")[1])

  if(!document.getElementById("vcomments")) {
    new Valine({
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm',
        visitor: true,
		    meta: ['nick','mail','link']
    });
  }
 
  
    


    const url = document.getElementById("iframeUrl").value;

    function observe (el, options, callback) {
      var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
      var observer = new MutationObserver(callback)
      observer.observe(el, options)
    }

    var options = {
        childList: true,
        subtree: true,
        characterData: true
      }
    observe(document.body, options, (records, instance) => {
    const height = document.body.scrollHeight;
    parent.postMessage(height,url);
    })
    if(pageurl.split(langss + "/")[1]) parent.postMessage(pageurl.split(langss + "/")[1],url);
    

    if(document.querySelector("#notFound")) parent.postMessage("我404了",url);

</script>
</body>
</html>
